package com.hb.core.pojo.project.evaluation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hb.core.pojo.project.evaluation.dto.EvaluationThirdDTO;
import com.hb.core.pojo.project.evaluation.entity.EvaluationThird;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 专家三级评审表 Mapper 接口
 * </p>
 *
 * @author jinhaolin
 * @since 2022-04-13
 */
public interface EvaluationThirdMapper extends BaseMapper<EvaluationThird> {

    /**
     * 根据评审点id和专家id获取评审结果列表
     * @param sectionId
     * @param reviewPointId
     * @param expertId
     * @return
     */
    List<EvaluationThirdDTO> listByReviewPointIdAndExpertId(@Param("sectionId") Long sectionId,
                                                            @Param("reviewPointId") Long reviewPointId,
                                                            @Param("expertId") Long expertId,
                                                            @Param("secondReviewItemId") Long secondReviewItemId);

    List<EvaluationThird> findEvaluationThirdList(EvaluationThird evaluationThird);

    /**
     * 根据三级评审点id获取已评审并共享的数据
     * @param sectionId
     * @param thirdReviewItemId
     * @return
     */
    List<EvaluationThirdDTO> findFinishedScoreAndShareBySectionIdAndThirdReviewItemId(@Param("sectionId") Long sectionId,
                                                                              @Param("thirdReviewItemId") Long thirdReviewItemId);

    /**
     * 查询未淘汰的企业列表
     * @return
     */
    List<Long> findOrgIdListNoEliminate(@Param("sectionId") Long sectionId,
                                        @Param("secondReviewItemId") Long secondReviewItemId);

    /**
     * 修改评审状态
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    Integer editEvaluationStatus(@Param("sectionId") Long sectionId,
                                 @Param("secondReviewItemId") Long secondReviewItemId,
                                 @Param("evaluationStatus") Integer evaluationStatus);


    /**
     * 修改专家对应三级评审点的得分和状态
     * @author tian
     * @date 2022-4-20 15:47
     * @param evaluationThird
     * @return java.lang.Integer
     */
    Integer updateFinalScoreByExpertIdAndThirdReviewItemId(EvaluationThird evaluationThird);


    /**
     * 查询当前企业是否淘汰
     * @author tian
     * @date 2022-4-20 16:53
     * @param sectionId
     * @return java.lang.Integer
     */
    Integer countBySectionIdAndOrgIdAndEliminateFlag(@Param("sectionId") Long sectionId, @Param("orgId") Long orgId);

    List<EvaluationThirdDTO> listEvaluationThirdDTO(@Param("sectionId") Long sectionId,
                                                    @Param("secondReviewItemId")Long secondReviewItemId,
                                                    @Param("firstReviewItemType") Integer firstReviewItemType);

    /**
     * 判断提交的数据是否有已汇总的
     * @return
     */
    Integer evaluationThirdHaveSummaryData(@Param("idList") List<Long> idList);

    /**
     * 查询被淘汰的企业id列表
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    List<Long> findOrgIdListEliminate(@Param("sectionId") Long sectionId, @Param("secondReviewItemId")Long secondReviewItemId);

    /**
     * 更新企业的淘汰状态
     * @param sectionId
     * @param secondReviewItemId
     * @param idList
     * @return
     */
    Integer updateOrgEliminateStatus(@Param("sectionId") Long sectionId, @Param("secondReviewItemId") Long secondReviewItemId, @Param("idList") List<Long> idList);


    /**
     * 取消企业淘汰状态
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    Integer cancelOrgEliminateStatus(@Param("sectionId") Long sectionId, @Param("secondReviewItemId") Long secondReviewItemId);

}
